package com.xuchaotong.mapstruct;

import com.alibaba.fastjson.JSON;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

/**
 * @author EASON.TONG
 * @create 2021/06/04
 **/
@Slf4j
public class UserConvertTest {


    @Test
    public void testToEntity(){
        UserDO userDO = new UserDO();
        userDO.setId(10L);
        userDO.setNickName("Eason");
        userDO.setRealName("chenyixun");
        userDO.setPhone("13577778888");
        User user = UserConvert.INSTANCE.toEnity(userDO);

        System.out.println(JSON.toJSONString(user));
    }

    @Test
    public void testToEntityList(){

        List<UserDO> list = new ArrayList<>();
        UserDO userDO = new UserDO();
        userDO.setId(10L);
        userDO.setNickName("Eason");
        userDO.setRealName("chenyixun");
        userDO.setPhone("13577778888");
        list.add(userDO);

        userDO = new UserDO();
        userDO.setId(11L);
        userDO.setNickName("Jenny");
        userDO.setRealName("lilili");
        userDO.setPhone("13577776666");
        list.add(userDO);

        List<User> result = UserConvert.INSTANCE.toEntityList(list);

        System.out.println(JSON.toJSONString(result));
    }
}
